package leetcode_2601_2700;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

public class LeeCode_2611 {
    public static void main(String[] args) {

    }
    private static int miceAndCheese(int[] reward1, int[] reward2, int k) {
        int n = reward1.length;
        int ans = 0;
        int[][] cha = new int[n][2];
        for (int i = 0; i < n; i++) {
            cha[i][0] = reward1[i] - reward2[i];
            cha[i][1] = i;
        }
        Arrays.sort(cha, (o1, o2) -> o2[0] - o1[0]);
        for (int i = 0; i < k; i++) {
            ans += reward1[cha[i][1]];
        }
        for (int i = k; i < n; i++) {
            ans += reward2[cha[i][1]];
        }
        return ans;
    }
}
